import time
import unittest
from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.support.select import Select


class UnittestFireFoxDriver(unittest.TestCase):
    """
        driver 代表的是 浏览器 驱动对象
    """
    driver = None

    @classmethod
    def setUpClass(cls) -> None:
        cls.service = Service(executable_path='../day01/driver_exe/geckodriver.exe')
        cls.driver = webdriver.Firefox(service=cls.service)

    def test_element_double_click(self):
        """上传图片并且截图的操作"""
        self.driver.get('file:///D:/SoftWare/testhtml/exam/House.html')

        # 测试网页中的 上图 文件的操作
        file = self.driver.find_element(By.XPATH, "//input[@type='file']")
        file.send_keys(
            'C:\\Users\\edz\\Desktop\\pythonStudy-2-15\\seleniumStudy\\ltd\\hanamaki\\study\\selenium\\day03\\UnittestFireFox_upload_file01.py')

        # 在脚本中 实现 截图的  操作
        self.driver.get_screenshot_as_file('D:\\filePng.png')

    @classmethod
    def tearDownClass(cls) -> None:
        # cls.driver.close()
        # cls.driver.quit()
        pass


if __name__ == '__main__':
    pass
